﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApp.Models;
using Facebook;

namespace WebApp.Controllers
{
    public abstract class ApplicationController : Controller
    {
        /// <summary>
        /// Called before any action is called
        /// </summary>
        /// <param name="context"></param>
        override protected void OnActionExecuting(
            ActionExecutingContext context)
        {
            if (HttpContext.Session["authToken"] != null)
            {
                try
                {
                    String authToken = HttpContext.Session["authToken"].ToString();
                    Person.Ref person = new Person.Ref("me");
                    person.Populate(authToken);
                    ViewData["ProfileModel"] = person;
                }
                catch (Exception e)
                {
                }
            }
        }
    }
}
